package com.bit.forum.controller;


import com.bit.forum.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

@Api(tags = "测试类相关接口")
@RequestMapping("/test")
@RestController
public class TestController {

    @ApiOperation("测试接口1,提示你好")
    @GetMapping ("/hello")
    public String hello(){
        return "hello...";
    }

    @ApiOperation("测试接口4,按传入的名字显示")
    @PostMapping( "/helloByName")
    public String helloByName(@ApiParam("用户姓名") @RequestParam("name") String name){
        return "hello: "+name;
    }

    @ApiOperation("测试接口2,显示异常信息")
    @GetMapping("/t1")
    public String testException() throws Exception {
        throw new Exception("exception异常");
    }

    @ApiOperation("测试接口3,自定义异常信息")
    @PostMapping("t2")
    public String testApplicationException (){
        throw new ApplicationException("ApplicationException异常");
    }
}
